package com.lineage.server.datatables.lock;

import com.lineage.server.datatables.sql.CharItemsPowerTable;
import com.lineage.server.datatables.storage.CharItemsPowerStorage;
import com.lineage.server.templates.L1ItemPower_name;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class CharItemPowerReading {
  private final Lock _lock = new ReentrantLock(true);
  
  private final CharItemsPowerStorage _storage = (CharItemsPowerStorage)new CharItemsPowerTable();
  
  private static CharItemPowerReading _instance;
  
  public static CharItemPowerReading get() {
    if (_instance == null)
      _instance = new CharItemPowerReading(); 
    return _instance;
  }
  
  public void load() {
    this._lock.lock();
    try {
      this._storage.load();
    } finally {
      this._lock.unlock();
    } 
  }
  
  public void storeItem(int objId, L1ItemPower_name power) {
    this._lock.lock();
    try {
      this._storage.storeItem(objId, power);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      this._lock.unlock();
    } 
  }
  
  public void updateItem(int item_obj_id, L1ItemPower_name power) {
    this._lock.lock();
    try {
      this._storage.updateItem(item_obj_id, power);
    } finally {
      this._lock.unlock();
    } 
  }
}
